#include<bits/stdc++.h>
using namespace std;
const int mod = 998244353;
long long qmi(long long a,long long b)
{
	b %= mod - 1;
	long long res = 1;
	while(b)
	{
		if(b & 1) (res *= a) %= mod;
		(a *= a) %= mod;
		b >>= 1;
	}
	return res;
}
int n;
typedef struct{
	int a[19][19];
}AD;
AD tms(AD A,AD B)
{
	AD res;
	for(int i = 0;i < n;i++)
		for(int j = 0;j < n;j++)
			res.a[i][j] = 0;
	for(int i = 0;i < n;i++)
		for(int k = 0;k < n;k++)
			for(int j = 0;j < n;j++)
				res.a[i][j] = (res.a[i][j] + 1ll * A.a[k][j] * B.a[i][k]) % mod;
	return res;
}
vector<int> Tms(vector<int>& A,AD& B)
{
	vector<int> res(n);
	for(int i = 0;i < n;i++)
		for(int k = 0;k < n;k++)
			res[i] = (res[i] + 1ll * A[k] * B.a[i][k]) % mod;
	return res;
}
const int K = 5,base = 4000;
AD trn[K + 1][base + 3];
map<long long,long long> mp;
long long gtans(long long k)
{
	if(k < 0) return 0;
	if(mp[k]) return mp[k];
	long long p = k;
	vector<int> res(n);
	res[0] = 1;
	for(int i = 0;k;i++,k /= base) if(k % base)
		res = Tms(res,trn[i][k % base]);
	long long ans = 0;
	for(auto i:res)
		ans += i;
	return mp[p] = ans % mod;
}
long long m;
pair<long long,long long> sum[1 << 18 | 3];
long long a[19],b[19],tma[19];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("yt.in","r",stdin);
	freopen("yt.out","w",stdout);
	cin >> n >> m;
	for(int i = 0;i < n;i++)
		cin >> a[i] >> b[i],tma[i] = qmi(a[i],b[i] + 1);
	for(int i = 0;i < n;i++)
		for(int j = 0;j <= i;j++)
			trn[0][1].a[i][j] = a[i];
	for(int i = 0;i < K;i++)
	{
		for(int j = 2;j <= base;j++)
			trn[i][j] = tms(trn[i][1],trn[i][j - 1]);
		trn[i + 1][1] = trn[i][base];
	}
	long long ans = 1ll * mod * mod;
	for(int S = 0;S < (1 << n);S++)
	{
		sum[S].second = 1;
		for(int i = 0;i < n;i++) if(S & (1 << i))
		{
			sum[S] = {sum[S ^ (1 << i)].first + b[i] + 1,sum[S ^ (1 << i)].second * tma[i] % mod};
			break;
		}
		int w = 1;
		for(int i = 0;i < n;i++) if(S & (1 << i))
			w *= -1;
		ans += w * gtans(m - sum[S].first) * sum[S].second % mod;
	}
	cout << ans % mod << "\n";
	return 0;
}